<?php
class VehiculosModel extends CustomModel
{

    public function gpsInUse($idGps)
    {
        $vehiculosAbm = new ABM('vehiculos');
        return $vehiculosAbm->get(array('identificador_gps' => $idGps, 'status' => STATUS_ONLINE));
    }

    public function nuevoVehiculo($vehiculo)
    {
        $vehiculosAbm = new ABM('vehiculos');
        return $vehiculosAbm->insert($vehiculo);
    }

    public function getVehiculos($pageNumber)
    {
        $vehiculosAbm = new ABM('vehiculos');
        return $vehiculosAbm->getPaginated($pageNumber, array('status' => STATUS_ONLINE), 10, 'nombre ASC', true);
    }

    public function vehiculoExists($id)
    {
        $vehiculosAbm = new ABM('vehiculos');
        $vehiculo = $vehiculosAbm->get(array('idvehiculo' => $id, 'status' => STATUS_ONLINE));
        if ($vehiculo)
        {
            return $vehiculo[$id];
        }
        else
        {
            return false;
        }
    }
	public function patenteInUse($patente)
    {
        $vehiculosAbm = new ABM('vehiculos');
        return $vehiculosAbm->get(array('patente' => $patente, 'status' => STATUS_ONLINE));
    }
	
	
    public function borrarVehiculo($id)
    {
        $vehiculosAbm = new ABM('vehiculos');
        return $vehiculosAbm->update(array('idvehiculo' => $id), array('status' => STATUS_OFFLINE));
    }

    public function editarVehiculo($id, $vals)
    {
        $vehiculosAbm = new ABM('vehiculos');
        return $vehiculosAbm->update(array('idvehiculo' => $id), $vals);
    }

}
?>